package com.linshengjian.power.service.imp;

import com.linshengjian.core.BaseDao;
import com.linshengjian.core.BaseService;
import com.linshengjian.power.dao.UserDao;
import com.linshengjian.power.entity.UserEntity;
import com.linshengjian.power.model.User;
import com.linshengjian.power.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService extends BaseService<UserEntity, User, Integer> implements IUserService {

    @Autowired
    private UserDao userDao;


    @Override
    protected BaseDao<UserEntity, Integer> dao() {
        return userDao;
    }

    @Override
    protected UserEntity model2Entity(User model) {
        UserEntity entity = new UserEntity();
        entity.setId(model.getId());
        entity.setNickname(model.getNickname())
                .setPortrait(model.getPortrait());
        return entity;
    }

    @Override
    protected User entity2model(UserEntity entity) {
        User model = new User();
        model.setId(entity.getId());
        model.setNickname(entity.getNickname())
                .setPortrait(entity.getPortrait());
        return model;
    }
}
